package com.itcast.mallapplet.mapper;

import com.itcast.applet.dto.AddressDTO;
import com.itcast.applet.dto.AddressyDTO;
import com.itcast.applet.entity.Address;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AddressMapper {

    //获取地址的经纬度
    @Select("select * from address where user_id = #{userId}")
    List<AddressyDTO> getByUserId(Long userId);

    //存地址
    @Insert("insert into address VALUES (null,#{userId},#{name},#{address},#{lat},#{ing},#{sex},#{phone},#{status})")
    void insetAddAddress(Address address);

    //查询单个地址
    @Select("select * from address where id = #{id}")
    Address queryAddress(Long id);

    //查询全部用户地址
    @Select("select * from address where user_id = #{userId}")
    List<Address> queryAllAddress(Long userId);

    //修改地址
    void amendAddress(Address address);

    //批量删除地址
    void deleteAddressAll(List<Long> ids);
}
